﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;

namespace MetroTedPlayer
{
    public class TileHelper
    {
        private string TileXml
        {
            get
            {
                return 
                    "<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
                        "<tile>" +
                            "<visual lang=\"en-US\"" +
                                "<binding template=\"TileSquareImage\">" + 
                                    "<image id=\"1\" src=\"PLACEHOLDER\"" +
                                "</binding>" +
                            "</visual>" +
                        "</tile>";
            }
        }

        public void UpdateTileWithImage(string imageUrl)
        {
            var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareImage);
            var notification = new TileNotification(tileXml);
            var upd = TileUpdateManager.CreateTileUpdaterForApplication();


            //notification = new TileNotification(newTileContent);
            upd.Update(notification);
        }

        //XmlDocument newTileContent = new XmlDocument();
        //XmlElement root = newTileContent.CreateElement("tile");
        //XmlElement visual = newTileContent.CreateElement("visual");
        //XmlElement binding = newTileContent.CreateElement("binding");
        //XmlElement image = newTileContent.CreateElement("image");

        //newTileContent.AppendChild(root);
        //root.AppendChild(visual);
        //visual.AppendChild(binding);
        //binding.AppendChild(image);
        //image.SetAttribute("id", "1");
        //image.SetAttribute("src", imageUrl);
        //image.SetAttribute("alt", "TedPlayer");
    }
}
